package reflect;

import java.lang.reflect.Constructor;

public class ReflectDemo3 {
    public static void main(String[] args) throws Exception {
        Person p  = new Person("张三");
        System.out.println(p);

        Class<?> cls = Class.forName("reflect.Person");

        Constructor<?> c = cls.getConstructor(String.class);
        Object obj = c.newInstance("吴羽");
        System.out.println(obj);

        Constructor<?> c2 = cls.getConstructor(String.class, int.class);
        Object obj2 = c2.newInstance("王五", 20);
        System.out.println(obj2);
    }
}
